using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Carmall.Entity;
using Carmall.IDAL;

namespace Carmall.DAL
{
	/// <summary>
	/// Shipmentaddress 的摘要说明。
	/// </summary>
	public class Shipmentaddress : BaseDAL<ShipmentaddressInfo>, IShipmentaddress
	{
		#region 对象实例及构造函数

		public static Shipmentaddress Instance
		{
			get
			{
				return new Shipmentaddress();
			}
		}
		public Shipmentaddress() : base("shipmentaddress","ShipmentID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override ShipmentaddressInfo DataReaderToEntity(IDataReader dataReader)
		{
			ShipmentaddressInfo shipmentaddressInfo = new ShipmentaddressInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			shipmentaddressInfo.ShipmentID = reader.GetInt64("ShipmentID");
			shipmentaddressInfo.UserID = reader.GetInt64("UserID");
			shipmentaddressInfo.Contact = reader.GetString("Contact");
			shipmentaddressInfo.Address = reader.GetString("Address");
			shipmentaddressInfo.ZipCode = reader.GetString("ZipCode");
			shipmentaddressInfo.PhoneNumber = reader.GetString("PhoneNumber");
			shipmentaddressInfo.Notes = reader.GetString("Notes");
			
			return shipmentaddressInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(ShipmentaddressInfo obj)
		{
		    ShipmentaddressInfo info = obj as ShipmentaddressInfo;
			Hashtable hash = new Hashtable(); 
			
			hash.Add("ShipmentID", info.ShipmentID);
 			hash.Add("UserID", info.UserID);
 			hash.Add("Contact", info.Contact);
 			hash.Add("Address", info.Address);
 			hash.Add("ZipCode", info.ZipCode);
 			hash.Add("PhoneNumber", info.PhoneNumber);
 			hash.Add("Notes", info.Notes);
 				
			return hash;
		}

    }
}